/**
 * 2016，thor.com，all rights reserved。
 * 
 * Project：		palmmall-core
 * Filename：	SPasswordInfoConverter.java
 * Created：		2016年7月30日
 * Creator：		wolv
 */
package com.thor.palmmall.rest.statement.converter;

import org.springframework.core.convert.converter.Converter;

import com.thor.commons.entity.UCN;
import com.thor.palmmall.rest.statement.ASubjectDetail;
import com.thor.palmmall.spi.statement.SSubjectDetail;

/**
 * @author wolv
 *
 */
public class ASubjectDetailConverter implements Converter<SSubjectDetail, ASubjectDetail> {

	public static ASubjectDetailConverter getInstance() {
		if (instance == null)
			instance = new ASubjectDetailConverter();
		return instance;
	}

	private static ASubjectDetailConverter instance;

	private ASubjectDetailConverter() {
	}

	@Override
	public ASubjectDetail convert(SSubjectDetail source) {
		if (source == null)
			return null;

		ASubjectDetail target = new ASubjectDetail();
		target.setBeginDate(source.getBeginDate());
		target.setEndDate(source.getEndDate());
		target.setPayedTotal(source.getPayedTotal());
		target.setPayTotal(source.getPayTotal());
		target.setSubject(UCN.newInstance(source.getSubject()));
		target.setUnpayedTotal(source.getUnpayedTotal());
		target.setAccId(source.getAccId());
		target.setConfirmed(source.getConfirmed());

		return target;
	}

}
